﻿using Microsoft.AspNetCore.Mvc;
using ShoppingCart.Models;

namespace ShoppingCart.Controllers
{
    /// <summary>
    /// 用户登录示例（模拟登录，调用购物车合并）
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    public class AuthController : ControllerBase
    {
        private readonly CartController _cartController; // 依赖注入或其他方式

        public AuthController(CartController cartController)
        {
            _cartController = cartController;
        }

        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost("login")]
        public async Task<IActionResult> Login([FromBody] LoginModel model)
        {
            // 这里应该有验证逻辑，比如检查用户名和密码是否正确，根据实际项目需求实现

            // 这里假设已经验证成功，模拟用户ID
            var userId = "user123";

            // 返回用户Id

            return Ok(new { Message = "登录成功", Data = userId });
        }
    }
}
